<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>AICloud 社区交流平台</title>
    <link rel="icon" href="./layui/public/favicon.ico">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="./layui/css/layui.css" rel="stylesheet">
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">AICloud 社区交流平台</div>
        <!-- 对话导航 -->
        <ul id="chat-nav" class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>
            <li class="layui-nav-item layui-hide-xs layui-this"><a lay-on="nav-change-content"
                                                                   lay-data="chat-gpt-content"
                                                                   href="javascript:;">ChatGPT</a></li>
            <li class="layui-nav-item layui-hide-xs"><a lay-on="nav-change-content" lay-data="chat-toyi-content"
                                                        href="javascript:;">通义千问</a></li>
            <li class="layui-nav-item layui-hide-xs"><a lay-on="nav-change-content" lay-data="chat-xunfe-content"
                                                        href="javascript:;">讯飞星火</a></li>
            <li class="layui-nav-item layui-hide-xs"><a lay-on="nav-change-content" lay-data="chat-wexin-content"
                                                        href="javascript:;">文心一言</a></li>
        </ul>
        <!-- 绘图导航-->
        <ul id="draw-nav" class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>
            <li class="layui-nav-item layui-hide-xs layui-this"><a lay-on="nav-change-content"
                                                                   lay-data="draw-gpt-content"
                                                                   href="javascript:;">ChatGPT</a></li>
            <li class="layui-nav-item layui-hide-xs"><a lay-on="nav-change-content" lay-data="draw-toyi-content"
                                                        href="javascript:;">通义千问</a></li>
            <li class="layui-nav-item layui-hide-xs"><a lay-on="nav-change-content" lay-data="draw-xunfe-content"
                                                        href="javascript:;">讯飞星火</a></li>
            <li class="layui-nav-item layui-hide-xs"><a lay-on="nav-change-content" lay-data="draw-wexin-content"
                                                        href="javascript:;">文心一言</a></li>
        </ul>
        <!-- 话题导航 -->
        <ul id="discuss-nav" class="layui-nav layui-layout-left" style="display: none">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>
            <li class="layui-nav-item layui-hide-xs layui-this"><a lay-on="nav-change-content"
                                                                   lay-data="discuss-content"
                                                                   href="javascript:;">推荐话题</a></li>
            <li class="layui-nav-item layui-hide-xs"><a lay-on="nav-change-content" lay-data="discuss-content-new"
                                                        href="javascript:;">最新话题</a></li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
                <a href="javascript:;">
                    <img src="//unpkg.com/outeres@0.0.10/img/layui/icon-v2.png" class="layui-nav-img">
                    tester
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="javascript:;">Your Profile</a></dd>
                    <dd><a href="javascript:;">Settings</a></dd>
                    <dd><a href="javascript:;">Sign out</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-more-vertical"></i>
                </a>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">AI 工具箱</a>
                    <dl class="layui-nav-child">
                        <dd><a class="layui-this" lay-on="chat-nav-show" href="javascript:;">对话</a></dd>
                        <dd><a lay-on="draw-nav-show" href="javascript:;">绘图</a></dd>
                    </dl>
                </li>
                <li lay-on="discuss-nav-show" class="layui-nav-item"><a href="javascript:;">话题讨论社区</a></li>
                <li class="layui-nav-item"><a href="javascript:;">关于AICloud</a></li>
            </ul>
        </div>
    </div>
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <div id="chat-gpt-content" class="layui-card layui-panel">
                <div class="layui-card-header layui-font-16" style="font-weight: bold">
                    chatgpt问题
                </div>
                <div class=" layui-card-body">
                    chatgpt答案
                </div>
            </div>

            <div id="chat-toyi-content" class="layui-card layui-panel" style="display: none">
                <div class="layui-card-header layui-font-16" style="font-weight: bold">
                    通义千问问题
                </div>
                <div class="layui-card-body">
                    通义千问答案
                </div>
            </div>
            <div id="chat-xunfe-content" class="layui-card layui-panel" style="display: none">
                <div class="layui-card-header layui-font-16" style="font-weight: bold">
                    讯飞星火问题
                </div>
                <div class="layui-card-body">
                    讯飞星火答案
                </div>
            </div>
            <div id="chat-wexin-content" class="layui-card layui-panel" style="display: none">
                <div class="layui-card-header layui-font-16" style="font-weight: bold">
                    文心一言问题
                </div>
                <div class="layui-card-body">
                    文心一言答案
                </div>
            </div>
            <!-- 画图AI切换-->
            <div id="draw-gpt-content" class="layui-card layui-panel" style="display: none">
                <div class="layui-card-header layui-font-16" style="font-weight: bold">
                    绘图 chatgpt问题
                </div>
                <div class=" layui-card-body">
                    绘图 chatgpt答案
                </div>
            </div>

            <div id="draw-toyi-content" class="layui-card layui-panel" style="display: none">
                <div class="layui-card-header layui-font-16" style="font-weight: bold">
                    绘图 通义千问问题
                </div>
                <div class="layui-card-body">
                    绘图 通义千问答案
                </div>
            </div>
            <div id="draw-xunfe-content" class="layui-card layui-panel" style="display: none">
                <div class="layui-card-header layui-font-16" style="font-weight: bold">
                    绘图 讯飞星火问题
                </div>
                <div class="layui-card-body">
                    绘图 讯飞星火答案
                </div>
            </div>
            <div id="draw-wexin-content" class="layui-card layui-panel" style="display: none">
                <div class="layui-card-header layui-font-16" style="font-weight: bold">
                    绘图 文心一言问题
                </div>
                <div class="layui-card-body">
                    绘图 文心一言答案
                </div>
            </div>
            <!-- 话题讨论内容-->
            <div id="discuss-content" class="layui-card layui-panel" style="display: none">
                <div class="layui-card-header layui-font-16" style="font-weight: bold">
                    推荐详情讨论
                </div>
                <div class="layui-card-body">
                    讨论内容
                </div>
            </div>
            <div id="discuss-content-new" class="layui-card layui-panel" style="display: none">
                <div class="layui-card-header layui-font-16" style="font-weight: bold">
                    最新讨论话题
                </div>
                <div class="layui-card-body">
                    讨论内容
                </div>
            </div>
        </div>
    </div>
    <div id="footer-chat" class="layui-footer"
         style="height: 80px;line-height: 80px; display: flex; align-items: center; justify-content: center;">
        <div style="flex: 1; margin-left: 50px; display: flex; align-items: center;">
            <input id="question-input" type="text" name="" placeholder="请输入问题？" class="layui-input"
                   style="flex: 1; margin-right: 10px;">
            <button type="button" class="layui-btn layui-btn-radius" lay-on="question-send">发送问题</button>
        </div>
    </div>
</div>

<script src="./layui/layui.js"></script>
<script>
    //JS
    layui.use(['element', 'layer', 'util', 'jquery'], function () {
        var element = layui.element;
        var layer = layui.layer;
        var util = layui.util;
        var jQuery = layui.$;
        // 默认当前是对话功能
        var question_type = "chat";

        util.on('lay-on', {
            // 显示对话
            'chat-nav-show': function () {
                jQuery('#chat-nav').show();
                jQuery('#discuss-nav').hide();
                jQuery('#draw-nav').hide();

                var showDivId = "chat-gpt-content";
                // 只显示自己的内容
                jQuery("#" + showDivId).show();
                // 隐藏同级别其他内容
                jQuery("#" + showDivId).siblings().hide();
                jQuery('#chat-nav').find("li").removeClass('layui-this');
                jQuery('#chat-nav').find("li").eq(1).addClass("layui-this");
                jQuery('#footer-chat').show();
            },
            // 显示绘图
            'draw-nav-show': function () {
                jQuery('#chat-nav').hide();
                jQuery('#discuss-nav').hide();
                jQuery('#draw-nav').show();

                var showDivId = "draw-gpt-content";
                // 只显示自己的内容
                jQuery("#" + showDivId).show();
                // 隐藏同级别其他内容
                jQuery("#" + showDivId).siblings().hide();

                // 默认选中第一个
                jQuery('#draw-nav').find("li").removeClass('layui-this');
                jQuery('#draw-nav').find("li").eq(1).addClass("layui-this");
                jQuery('#footer-chat').show();
                question_type = "draw";
            },
            // 显示话题
            'discuss-nav-show': function () {
                jQuery('#chat-nav').hide();
                jQuery('#discuss-nav').show();
                jQuery('#draw-nav').hide();

                var showDivId = "discuss-content";
                // 只显示自己的内容
                jQuery("#" + showDivId).show();
                // 隐藏同级别其他内容
                jQuery("#" + showDivId).siblings().hide();
                // 默认选中第一个
                jQuery('#draw-nav').find("li").removeClass('layui-this');
                jQuery('#draw-nav').find("li").eq(1).addClass("layui-this");
                // 隐藏对话输入框
                jQuery('#footer-chat').hide();
            },
            'nav-change-content': function (e) {
                var showDivId = jQuery(e).attr("lay-data");
                // 只显示自己的内容
                jQuery("#" + showDivId).show();
                // 隐藏同级别其他内容
                jQuery("#" + showDivId).siblings().hide();
            },
            // 发送问题
            'question-send': function () {
                var question = jQuery('#question-input').val();
                if (question == null || question == "") {
                    layer.msg("请先输入问题！");
                    return;
                }
                if (question_type == "chat") {
                    jQuery.ajax({
                        url: "/api/ai-cloud/v1/openai/chat",
                        type: "POST",
                        data: {
                            question: question
                        },
                        success: function (result) {
                            // TODO 进行消息返回渲染
                        }
                    })
                } else if (question_type == "draw") {
                    jQuery.ajax({
                        url: "/api/ai-cloud/v1/openai/draw",
                        type: "POST",
                        data: {
                            question: question
                        },
                        success: function (result) {
                            // TODO 进行消息返回渲染
                        }
                    })
                }
            }
        })

        //头部事件
        util.event('lay-header-event', {
            menuLeft: function (othis) { // 左侧菜单事件
                layer.msg('展开左侧菜单的操作', {icon: 0});
            },
            menuRight: function () {  // 右侧菜单事件
                layer.open({
                    type: 1,
                    title: '更多',
                    content: '<div style="padding: 15px;">处理右侧面板的操作</div>',
                    area: ['260px', '100%'],
                    offset: 'rt', // 右上角
                    anim: 'slideLeft', // 从右侧抽屉滑出
                    shadeClose: true,
                    scrollbar: false
                });
            }
        });
    });
</script>
</body>
</html>